<!-- 已报产工序 -->
<template>
	<view>
		<view class="header">
			<span>{{searchObj.deptName}}</span>
			<uv-tabs :list="list" @click="listClick"></uv-tabs>
		</view>
		<view class="header">
			<span>指令</span>
			<span class="blue">{{selectRow.lotNo}}</span>
			<span>缴库日期</span>
			<span class="blue">{{selectRow.slipDate}}</span>
			<span>类型</span>
			<span class="blue">{{selectType}}</span>
		</view>
		<view class="header">
			<uv-input v-model="number" placeholder="请输入序号"></uv-input>
			<uv-input v-model="progress" placeholder="请输入工序"></uv-input>
			<uv-input v-model="user" placeholder="请输入员工"></uv-input>
		</view>
		<view class="header">
			<uv-button type="primary" text="搜索" @click="search"></uv-button>
			<uv-button type="primary" text="重置" @click="reset"></uv-button>
		</view>


		<uni-table border stripe emptyText="暂无更多数据">
			<!-- 表头行 -->
			<uni-tr>
				<uni-th :width="50" align="center">指令号</uni-th>
				<uni-th :width="50" align="center">序号</uni-th>
				<uni-th :width="50" align="center">工序</uni-th>
				<uni-th :width="50" align="center">人员</uni-th>
				<uni-th :width="50" align="center">报产数</uni-th>
				<uni-th :width="50" align="center">操作</uni-th>
			</uni-tr>
			<!-- 表格数据行 -->
			<uni-tr v-for="item in tableList">
				<uni-td>{{item.lotNo}}</uni-td>
				<uni-td>{{item.seqNo}}</uni-td>
				<uni-td>{{item.processName}}</uni-td>
				<uni-td>{{item.workName}}</uni-td>
				<uni-td>{{item.qty2}}</uni-td>
				<uni-td>
					<view class="uni-group">
						<button class="uni-button" size="mini" type="primary" @click="removeOne(item)">删除</button>
					</view>
				</uni-td>
			</uni-tr>
		</uni-table>

		<uv-tabbar iconSize="30" :border="false" :value="tabbarValue" @change="tabbarChange">
			<uv-tabbar-item text="报产作业" icon="order"></uv-tabbar-item>
			<uv-tabbar-item text="产值查询" icon="search"></uv-tabbar-item>
			<uv-tabbar-item text="退出" icon="play-right"></uv-tabbar-item>
		</uv-tabbar>

		<uv-notify ref="notify" type="error"></uv-notify>
		<uv-notify ref="notify2" type="success"></uv-notify>
	</view>
</template>

<script>
	import inputNum from '@/components/inputNum/inputNum.vue'
	export default {
		data() {
			return {
				tableList: [],
				tabbarValue: 0,
				selectType: '',
				number: '',
				progress: '',
				workName: '',
				user: '',
				list: [{
					name: '已报产工序',
				}, {
					name: '待报产工序',
				}, ],
				selectRow: {},
				searchObj: {},
				status: ''
			}
		},
		methods: {
			reset() {
				this.number = ''
				this.progress = ''
				this.user = ''
			},
			removeOne(item) {
				uni.request({
					url: '/kl/pad/stitchProductionReport/deleteReportProcess',
					header: {
						'Authorization': uni.getStorageSync('token'), //自定义请求头信息
					},
					data: {
						...this.searchObj,
						...this.selectRow,
						...item,
					},
					method: "POST",
					success: (res) => {
						if (res.data.code === 200) {
							this.$refs.notify2.show({
								message: res.data.message
							});
							this.getTableList()
						} else {
							this.$refs.notify.show({
								message: res.data.message
							});
						}
					}
				});
			},
			listClick(item) {
				if (item.name === '待报产工序') {
					uni.redirectTo({
						url: '/pages/batchReporting/batchReporting?selectRow=' + JSON.stringify(
							this.selectRow) + '&searchObj=' + JSON.stringify(this.searchObj)
					})
				}
			},
			search() {
				this.getTableList()
			},
			combinedReport() {
				this.userDialogShow = true
			},
			tabbarChange(index) {
				this.tabbarValue = index
				if (index === 1) {
					uni.reLaunch({
						url: '/pages/outputSearch/outputSearch'
					})
				}
				if (index === 2) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
			},
			getTableList() {
				uni.request({
					url: '/kl/pad/stitchProductionReport/getReportProcessDetails',
					header: {
						'Authorization': uni.getStorageSync('token'), //自定义请求头信息
					},
					data: {
						...this.selectRow,
						seqNo: this.number,
						processName: this.progress,
						workName: this.user,
						sortNo: this.status
					},
					method: "POST",
					success: (res) => {
						if (res.data.code === 200) {
							this.tableList = res.data.data.list
						} else {
							this.$refs.notify.show({
								message: res.data.message
							});
						}
					}
				});
			},
		},
		onLoad(data) {
			this.selectRow = JSON.parse(data.selectRow)
			this.searchObj = JSON.parse(data.searchObj)
			this.status = data.status
			this.selectRow.orderType === 0 ? this.selectType = '正单' : this.selectType = '补单'
			this.getTableList()
		}
	}
</script>

<style>
	.header {
		padding: 10rpx 30rpx 10rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: 26rpx;
	}

	.blue {
		color: #629BC9;
	}

	.uni-group {
		display: flex;
		align-items: center;
	}

	.btn {
		margin: 30rpx;
	}
</style>